package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * TODO
 *
 * @Author mr.zhao
 * @Date 2025/5/25 22:59
 */
@Mapper
public interface ShoppingCartMapper {

	/**\
	 * 条件查询
	 * @param shoppingCart
	 * @return
	 */
	List<ShoppingCart> list(ShoppingCart shoppingCart);

	/**
	 * 更新商品数量
	 * @param shoppingCart
	 */
	void updateNumberById(ShoppingCart shoppingCart);

	/**
	 * 新增数据
	 * @param shoppingCart
	 */
	@Insert("insert into shopping_cart (name, user_id, dish_id, setmeal_id, dish_flavor, number, amount, image, create_time) " +
			" values (#{name},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{image},#{createTime})")
	void insert(ShoppingCart shoppingCart);

	/**
	 * 清空购物车
	 * @param currentId
	 */
	void deleteByUseId(Long currentId);

	/**
	 * 批量添加购物车数据
	 * @param shoppingCartList
	 */
	void insertBatch(List<ShoppingCart> shoppingCartList);
}
